#include "../header.h"

/**
 * @函数原型: int access(const char * pathname,int mode);
 * @函数功能: 判断文件是否有某些权限
 * @参数说明: 
 * @       参数1: 文件名
 * @       参数2: 权限名称  F_OK  R_OK W_OK X_OK
 * @返回值: 权限存在返回0 不存在返回-1；
 * @param {int} argc
 */
int main(int argc, char const *argv[])
{
    if(argc < 2)
    {
        perror("usage:a.out + filename\n");
        return -1;
    }

    //! 存在判断
    if(!access(argv[1],F_OK))
        printf("this file is exits\n");
    else
        printf("this file is not exits\n");
    
    //? 读写权限的判断
    if(!access(argv[1],R_OK|W_OK))
        printf("this file has read mode or write mode\n");
    else
        printf("this file has not read mode or write mode\n");

    return 0;
}
